import caseHttpRequest from "@/db/oralCase"
import type * as Case from "./type"
import { useUserStore } from "@/store"

// 获取闽南药膳分类
export function getAllCaseCategory() {
  return caseHttpRequest.getAllCaseCategory<Case.CaseCategoryItem[]>()
}

// 获取闽南药膳分类(分页)
export function getCaseCategoryList(page: number = 1, pageSize: number = 10, searchQuery: any = null) {
  return caseHttpRequest.getCaseCategoryList<Case.CaseCategoryItem[]>(page, pageSize, searchQuery)
}

// 获取闽南药膳分类详情
export function getCaseCategoryInfo(id: string) {
  return caseHttpRequest.getCaseCategoryInfo<Case.CaseCategoryItem>(id)
}

// 更新闽南药膳分类
export function updateCaseCategory(id: string, data: Case.CaseCategoryItem) {
  return caseHttpRequest.updateCateCategory(id, data)
}

// 新增闽南药膳分类
export function addCaseCategory(data: Case.CaseCategoryItem) {
  return caseHttpRequest.addCaseCategory(data)
}

// 删除闽南药膳分类
export function deleteCaseCategory(id: string) {
  return caseHttpRequest.deleteCaseCategory(id)
}

// 获取闽南药膳(分页)
export function getCaseList(page: number = 1, pageSize: number = 10, searchQuery: any = null) {
  return caseHttpRequest.getCaseRecords<Case.CaseCategoryItem[]>(page, pageSize, searchQuery)
}

// 获取闽南药膳详情
export function getCaseInfo(id: string) {
  const userStore = useUserStore()
  return caseHttpRequest.getCaseInfo<Case.OralCaseItem>(id, userStore.id!)
}

//新增闽南药膳
export function addCase(data: Case.OralCaseItem) {
  return caseHttpRequest.addCaseRecord(data)
}

// 更新闽南药膳
export function updateCase(id: string, data: Case.OralCaseItem) {
  return caseHttpRequest.updateCaseRecord(id, data)
}

// 删除闽南药膳
export function deleteCaseRecord(id: string) {
  return caseHttpRequest.deleteCaseRecord(id)
}

// 收藏案例
export function collectCase(user_id: string, case_id: string) {
  return caseHttpRequest.collectCase(user_id, case_id)
}

// 取消收藏案例
export function unCollectCase(user_id: string, case_id: string) {
  return caseHttpRequest.unCollectCase(user_id, case_id)
}

// 获取收藏案例(分页)
export function getCollectCaseList(page: number = 1, pageSize: number = 10) {
  const userStore = useUserStore()
  return caseHttpRequest.getCollectCaseList<Case.CaseCategoryItem[]>(page, pageSize, userStore.id!)
}
